<template>
    <div>
        <van-nav-bar title="我的点赞" fixed placeholder />
        <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="loadMore">
            <article-item v-for="item in articleList" :key="item.id" :article="item"></article-item>
        </van-list>
    </div>
</template>

<script>
import { getlikecollectionlist } from "@/api/article";
import articleItem from '@/components/articleItem.vue'
export default {
    components:{
        articleItem,
    },
    data() {
        return {
            loading: true,
            finished: false,
            articleList: [],
            current: 1      //current 设置当前数据
        }
    },
    created() {
        // 调用接口，拉取数据  loadlist 加载函数
        this.loadlist();
    },
    methods: {
        async loadlist() {
            // 调用接口
            const res = await getlikecollectionlist({
                optType: 1,    //操作类型：1点赞2收藏
                page: this.current,   //当前页
            });
            console.log('点赞列表', res);

            //处理下一页
            this.current === 1 ? this.articleList = res.data.data.rows : this.articleList = [...this.articleList, ...res.data.data.rows]
            //关闭加载
            this.loading = false
            //判断是否有更多数据
            this.finished = this.current >= res.data.data.pageTotal
        },
        loadMore() {
            //加载下一页数据
            this.current++;
            //调用接口
            this.loadArticleList()
        },

    }
}
</script>

<style>

</style>